package com.example.portalfundacao;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class CalendarItemActivity extends Activity {

	public Calendar selectedDate = Calendar.getInstance();
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calendar_item);
        
        String date = getIntent().getStringExtra("date");
        String[] dateArr = date.split("-"); // date format is yyyy-mm-dd
        selectedDate.set(Integer.parseInt(dateArr[0]), Integer.parseInt(dateArr[1])-1, Integer.parseInt(dateArr[2]));
        
        TextView textDate = (TextView) findViewById(R.id.dataSelecionada);
        textDate.setText(new SimpleDateFormat("dd/MM/yyyy").format(selectedDate.getTime()));
        
        Button botaoAdd = (Button) findViewById(R.id.button1);
        botaoAdd.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				
				Toast.makeText(getApplicationContext(), "Adicionando Evento...", Toast.LENGTH_LONG).show();
				
			}
		});
        
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_calendar_item, menu);
        return true;
    }
}
